use super::{atomic,internal,types};

/**
 * !todo: debug support for valgrind & asan 
 * #[cfg(MI_TRACK_VALGRIND)]
 * pub const MI_TRACK_ENABLED: bool  = 1;
 * pub const MI_TRACK_HEAP_DESTROYS: bool  = 1;
 * pub const MI_TRACK_TOOL: String = "valgrind";
 */

pub const MI_TRACK_ENABLED: bool = false;
pub const MI_TRACK_HEAP_DESTROY: bool = false;
pub const MI_TRACK_TOOL: &str = "none";
pub fn mi_track_malloc(p: *mut u8, reqsize: usize, zero: bool) {
    // todo( allocate tracking )
}
pub fn mi_track_free_size(p: *mut u8, _size: usize) {
    // todo( free tracking )
}
#[macro_export]
macro_rules! mi_track_resize {
    ($p:expr, $oldsize:expr, $newsize:expr) => {
        mi_track_free_size($p, $oldsize);
        mi_track_malloc($p, $newsize, false);
    };
}

pub fn mi_track_mem_noaccess(p: *mut u8, size: usize) {
    // todo
}

pub fn mi_track_mem_defined(p: *mut u8, size: usize) {
    // 
}

pub fn mi_track_mem_undefined(p: *mut u8, size: usize) {
    // 
}

pub fn mi_track_init() {
    // 
}
#[macro_export]
macro_rules! mi_track_align {
    ($p:expr, $alignedp:expr, $offset:expr, $size:expr) => {
        mi_track_mem_noaccess($p, $offset);
    };
}
#[macro_export]
macro_rules! mi_track_init_macro {
    () => {
        mi_track_init();
    };
}
#[macro_export]
macro_rules! mi_track_mem_defined_macro {
    ($p:expr, $size:expr) => {
        mi_track_mem_defined($p, $size);
    };
}
#[macro_export]
macro_rules! mi_track_mem_undefined_macro {
    ($p:expr, $size:expr) => {
        mi_track_mem_undefined($p, $size);
    };
}

#[cfg(MI_PADDING)]
#[macro_export]
macro_rules! mi_track_malloc {
    ($p:expr, $reqsize:expr, $zero:expr) => {
        if !$p.is_null() {
            mi_assert_internal(mi_usable_size($p) == $reqsize);
            mi_track_malloc_size($p, $reqsize, $reqsize, $zero);
        }
    };
}

#[cfg(not(MI_PADDING))]
#[macro_export]
macro_rules! mi_track_malloc {
    ($p:expr, $reqsize:expr, $zero:expr) => {
        if !$p.is_null() {
            mi_assert_internal(mi_usable_size($p) >= $reqsize);
            mi_track_malloc_size($p, $reqsize, $zero);
        }
    }
}